//
//  SelectAccountTableCell.m
//  ATMCash
//
//  Created by zhengchengfeng on 2024/9/9.
//

#import "SelectAccountTableCell.h"

@implementation SelectAccountTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        
        self.iconV = [[UIImageView alloc] init];
        [self.contentView addSubview:self.iconV];
        [self.iconV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(15);
            make.right.equalTo(self.contentView.mas_right).offset(-15);
            make.top.equalTo(self.contentView.mas_top).offset(7.5);
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-7.5);
        }];
        
        self.logoV = [[UIImageView alloc] init];
        [self.iconV addSubview:self.logoV];
        [self.logoV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.iconV.mas_left).offset(24);
            make.top.equalTo(self.iconV.mas_top).offset(24);
            make.width.with.height.equalTo(@28);
        }];
        
    
        self.nameLab = [Utility createLabel:[UIFont fontWithName:kFuturaBT size:16] color:RGB(255, 255, 255)];
        [self.iconV addSubview:self.nameLab];
        [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.logoV.mas_right).offset(5);
            make.centerY.equalTo(self.logoV.mas_centerY);
            make.right.equalTo(self.iconV.mas_right).offset(-40);
            make.height.equalTo(@24);
        }];
        
        self.selV = [[UIImageView alloc] init];
        [self.iconV addSubview:self.selV];
        [self.selV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.iconV.mas_right).offset(-12);
            make.top.equalTo(self.iconV.mas_top).offset(12);
            make.width.with.height.equalTo(@20);
        }];
        
        self.numLab = [Utility createLabel:[UIFont fontWithName:kFutura size:24] color:RGB(255, 239, 192)];
        [self.iconV addSubview:self.numLab];
        [self.numLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.iconV.mas_left).offset(24);
            make.bottom.equalTo(self.iconV.mas_bottom).offset(-49);
            make.right.equalTo(self.iconV.mas_right).offset(-24);
            make.height.equalTo(@24);
        }];
        self.name2Lab = [Utility createLabel:[UIFont fontWithName:kFuturaMedium size:13] color:RGB(255, 255, 255)];
        [self.iconV addSubview:self.name2Lab];
        [self.name2Lab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.iconV.mas_left).offset(24);
            make.top.equalTo(self.numLab.mas_bottom);
            make.right.equalTo(self.iconV.mas_right).offset(-24);
            make.height.equalTo(@25);
        }];
        
        
        CGFloat width = (kScreenWidth - 30 - 48)/3;
        
        self.fLab = [Utility createLabel:[UIFont fontWithName:kFuturaBTMedium size:18] color:RGB(255, 239, 192)];
        [self.iconV addSubview:self.fLab];
        [self.fLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.iconV.mas_left).offset(24);
            make.bottom.equalTo(self.iconV.mas_bottom).offset(-49);
            make.width.equalTo(@(width));
            make.height.equalTo(@24);
        }];
        self.fLab1 = [Utility createLabel:[UIFont fontWithName:kFuturaMedium size:13] color:RGB(255, 255, 255)];
        [self.iconV addSubview:self.fLab1];
        [self.fLab1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.fLab.mas_left);
            make.top.equalTo(self.fLab.mas_bottom);
            make.right.equalTo(self.fLab.mas_right);
            make.height.equalTo(@25);
        }];
        
        self.mLab = [Utility createLabel:[UIFont fontWithName:kFuturaBTMedium size:18] color:RGB(255, 239, 192)];
        [self.iconV addSubview:self.mLab];
        [self.mLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.fLab.mas_right);
            make.bottom.equalTo(self.iconV.mas_bottom).offset(-49);
            make.width.equalTo(@(width));
            make.height.equalTo(@24);
        }];
        self.mLab1 = [Utility createLabel:[UIFont fontWithName:kFuturaMedium size:13] color:RGB(255, 255, 255)];
        [self.iconV addSubview:self.mLab1];
        [self.mLab1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mLab.mas_left);
            make.top.equalTo(self.mLab.mas_bottom);
            make.right.equalTo(self.mLab.mas_right);
            make.height.equalTo(@25);
        }];
        
        self.Llab = [Utility createLabel:[UIFont fontWithName:kFuturaBTMedium size:18] color:RGB(255, 239, 192)];
        [self.iconV addSubview:self.Llab];
        [self.Llab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mLab.mas_right);
            make.bottom.equalTo(self.iconV.mas_bottom).offset(-49);
            make.right.equalTo(self.iconV.mas_right).offset(-24);
            make.height.equalTo(@24);
        }];
        self.Llab1 = [Utility createLabel:[UIFont fontWithName:kFuturaMedium size:13] color:RGB(255, 255, 255)];
        [self.iconV addSubview:self.Llab1];
        [self.Llab1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.Llab.mas_left);
            make.top.equalTo(self.Llab.mas_bottom);
            make.right.equalTo(self.Llab.mas_right);
            make.height.equalTo(@25);
        }];
        
        
    }
    return self;
}

- (void)setModel:(AccountVictoryModel *)model{
    _model = model;
    
    [self.logoV sd_setImageWithURL:[NSURL URLWithString:esString(model.spoon)]];
    
    self.nameLab.text = esString(model.please);
    
    
    
    
    
    if (model.isSelected) {
        self.selV.image = [UIImage imageNamed:@"icon_accountSel"];
    } else {
        self.selV.image = [UIImage imageNamed:@"icon_accountUnsel"];
    }
    
    if ([self.giggling integerValue] == 2) {
        
        self.iconV.image = [UIImage imageNamed:@"icon_bankBg"];
        self.numLab.hidden = NO;
        self.name2Lab.hidden = NO;
        
        self.numLab.text = esString(model.sorry);
        self.name2Lab.text = @"Account";
        
        self.fLab.hidden = YES;
        self.fLab1.hidden = YES;
        self.mLab.hidden = YES;
        self.mLab1.hidden = YES;
        self.Llab.hidden = YES;
        self.Llab1.hidden = YES;
        
       
        
        
    } else {
        self.iconV.image = [UIImage imageNamed:@"icon_cashBg"];
        self.numLab.hidden = YES;
        self.name2Lab.hidden = YES;
        
        self.fLab.text =  esString(model.awfully.sole);
        self.fLab1.text =  @"First Name";
        self.mLab.text =  esString(model.awfully.operas);
        self.mLab1.text =  @"Middle Name";
        self.Llab.text =  esString(model.awfully.wagner);
        self.Llab1.text =  @"Last Name";
        
        self.Llab.hidden = NO;
        self.Llab1.hidden = NO;
        self.mLab.hidden = NO;
        self.mLab1.hidden = NO;
        self.Llab.hidden = NO;
        self.Llab1.hidden = NO;
    }
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
